<template>
  <div class="right-container">
     <h3>{{count}}</h3>
     <button @click="add">按钮</button>
     <hr>
     <h4>接收到left的数据为:{{msgFromLeft}}</h4>
  </div>
</template>

<script>
import bus from '@/js/eventBus.js'
export default {
  data(){
    return{
      count:0,
      msgFromLeft:''
    }
  },
  methods:{
    add(){
      // 让子组件的数据自增
      this.count++;
      // 把自增的结果，传给父组件
      this.$emit('numerChange',this.count)
    }
  },
  created(){
    bus.$on('share',val=>{
      this.msgFromLeft = val
    })
  }
}
</script>

<style lang="less" scoped>
.right-container {
  padding: 0 20px 20px;
  background-color: orange;
  min-height: 250px;
  flex: 1;
}
</style>